home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-09 | 5.0 KB | 169 lines | [TEXT/PJMM] |
- {****************************************************}
- {}
- { CFSApp.p }
- {}
- { Application methods for the Flight Stability application. }
- {}
- { Copyright © 1995, Patrick Hew. All rights reserved. }
- {}
- {****************************************************}
-
-
- unit CFSApp;
-
- interface
-
- uses
- TCL, FSIntf;
-
- implementation
-
- const
- kExtraMasters = 4; (* number of extra master pointer blocks *)
- kRainyDay = 32000; (* total rainy day memory reserve size *)
- kCriticalBalance = 30000; (* portion of rainy day for critical operations *)
- kToolboxBalance = 20000; (* portion of rainy day for toolbox reserve *)
-
-
- { IFSApp }
- {}
- { Post: The flight stability application has been initialized. }
-
- procedure CFSApp.IFSApp;
-
- begin { IFSApp }
- IApplication(kExtraMasters, kRainyDay, kCriticalBalance, kToolboxBalance);
-
- { The parameters to IApplication are the number of times to call MoreMasters, }
- { the number of bytes of heap space to reserve for monitoring }
- { low memory situations, and the credit limit for memory requests. }
- { Four (4) is a reasonable number of MoreMasters calls, }
- { but you should determine a good number for your application }
- { by observing the heap using Lightsbug, }
- { TMON, or Macsbug. Set this parameter to zero, give your }
- { program a rigorous work-out, then look at the heap and count }
- { how many master pointer blocks have been allocated. Master }
- { pointer blocks are nonrelocatable and have a size of $100 }
- { (hex). You should call MoreMasters at least this many }
- { times -- add a few extra just to be safe. The purpose of all }
- { this preflighting is to prevent heap fragmentation. You }
- { don't want the Memory Manager to call MoreMasters and }
- { create a nonrelocatable block in the middle of your heap. By }
- { calling MoreMasters at the very beginning of the program, }
- { you ensure that these blocks are allocated in a group at the }
- { bottom of the heap. }
- { The memory reserve is a safeguard for handling low memory }
- { conditions and is used by the GrowMemory method in }
- { CApplication (check there for more comments). In general, }
- { your program should never request a memory block greater }
- { than this reserve size without explicitly checking in }
- { advance whether there is enough free memory to satisfy the }
- { the request. }
- { The credit limit specifies a cut-off level for memory }
- { requests which can tap the memory reserve. Requests larger }
- { than this size will not use the memory reserve when the }
- { system pleads for more memory. }
-
- end; { IFSApp }
-
-
- { SetUpFileParameters }
- {}
- { Post: The signature of the application has been set. }
-
- procedure CFSApp.SetUpFileParameters;
-
- begin { SetUpFileParameters }
- inherited SetUpFileParameters; { Be sure to call the default method }
-
- {*}
- { ** Although it's not an instance variable,}
- { ** this method is a good place to set the}
- { ** gSignature global variable. Set this global}
- { ** to your application's signature. You'll use it}
- { ** to create a file (see CFile.CreateNew).}
- { **}
- { *}
-
- gSignature := '????';
- end; { SetUpFileParameters }
-
-
- { MakeDesktop }
- {}
- { Post: The application has set up a desktop which allows floating windows. }
-
- procedure CFSApp.MakeDesktop;
-
- begin { MakeDesktop }
- new(CFWDesktop(gDesktop));
- CFWDesktop(gDesktop).IFWDesktop(SELF);
- end; { MakeDesktop }
-
-
- { DoCommand }
- {}
- { Post: The command with the given command id has been acted upon. }
-
- procedure CFSApp.DoCommand (theCommand: longint);
-
- begin { DoCommand }
- case theCommand of
-
- { Your commands go here (dummyCmd is given as an example) }
-
- cmdAbout: begin
- itsHelpDirector.DrawHelpWindow(ModeCredits);
- end; { doAbout }
-
- otherwise begin
- inherited DoCommand(theCommand);
- end; { otherwise }
-
- end; { case }
- end; { DoCommand }
-
-
- { StartUpAction }
- {}
- { Post: The game director has been created and its window selected. }
-
- procedure CFSApp.StartUpAction (numPreloads: Integer);
-
- var
- theGameDirector: CFSGameDirector;
- theHelpDirector: CFSHelpDirector;
-
- begin { StartupAction }
- new(theGameDirector);
- itsGameDirector := theGameDirector;
- itsGameDirector.IFSGameDirector(SELF);
- itsGameDirector.BuildWindow;
- itsGameDirector.GetWindow.Select;
-
- new(theHelpDirector);
- itsHelpDirector := theHelpDirector;
- itsHelpDirector.IFSHelpDirector(SELF);
- itsHelpDirector.BuildWindow;
- itsHelpDirector.GetWindow.Select;
-
- end; { StartupAction }
-
-
- { ExitApp }
- {}
- { Post: Memory allocated by the application has been disposed of. }
-
- procedure CFSApp.ExitApp;
-
- begin { ExitApp }
- { Because the game director and level documents are installed in the supervision heirarchy, }
- { the default methods handle disposal. All we need to do is reset our own pointers. }
-
- itsGameDirector := nil;
-
- inherited ExitApp;
- end; { ExitApp }
-
-
- end. { CFSApp }